/**
 * 3
 *  
 * @Author : Ruoyu Wang
 * @DateTime : 24-10-18 下午6:48
 */

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MOD = 1e9 + 7;

long long qmi(long long a, long long k) {
    long long res = 1;
    while (k > 0) {
        if (k % 2 == 1) {
            res = (res * a) % MOD;
        }
        a = (a * a) % MOD;
        k /= 2;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<int> nums(n);
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }

    long long res = 0;
    int total = 0;
    for (int num: nums) {
        total += num;
    }
    if (total % 3 == 0) {
        int tmp = total / 3;
        vector<int> f(tmp + 1, 0);
        f[0] = 1;
        for (int num: nums) {
            for (int i = tmp; i >= num; --i) {
                f[i] = (f[i] + f[i - num]) % MOD;
            }
        }
        res = f[tmp];
        int cnt = count(nums.begin(), nums.end(), 0);
        res = (res * qmi(2, cnt)) % MOD;
    }

    cout << res << endl;;

    return 0;
}